
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Particle filter &#8212; Bearing Vibration Diagnostics Toolbox 1.0 documentation</title>
    <link rel="stylesheet" href="_static/classic.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <script type="text/javascript" src="_static/language_data.js"></script>
    <script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="Acoustics functions" href="acoustics.html" />
    <link rel="prev" title="Statistical functions" href="stats.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="acoustics.html" title="Acoustics functions"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="stats.html" title="Statistical functions"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">Bearing Vibration Diagnostics Toolbox 1.0 documentation</a> &#187;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="module-pyvib.ParticleFilter">
<span id="particle-filter"></span><h1>Particle filter<a class="headerlink" href="#module-pyvib.ParticleFilter" title="Permalink to this headline">¶</a></h1>
<p>Particle filter class</p>
<dl class="class">
<dt id="pyvib.ParticleFilter.ParticleFilter">
<em class="property">class </em><code class="descclassname">pyvib.ParticleFilter.</code><code class="descname">ParticleFilter</code><span class="sig-paren">(</span><em>N</em>, <em>R</em>, <em>Q</em>, <em>model</em>, <em>nStates</em>, <em>nParameters</em>, <em>measuredStates</em>, <em>resampleAlways=False</em>, <em>resampleDebug=False</em><span class="sig-paren">)</span><a class="headerlink" href="#pyvib.ParticleFilter.ParticleFilter" title="Permalink to this definition">¶</a></dt>
<dd><p>A particle filter class</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>N</strong> (<em>int</em>) – Number of particles</li>
<li><strong>R</strong> (<em>float</em><em> or </em><em>array_like</em>) – Variance of measured states
len(R) == len(measuredStates)</li>
<li><strong>Q</strong> (<em>float</em><em> or </em><em>array_like</em>) – Variance of actuation error
Part of model</li>
<li><strong>model</strong> (<em>function</em><em>(</em><em>u</em><em>, </em><em>states</em><em>, </em><em>parameters</em><em>, </em><em>Q</em><em>)</em>) – <p>Model that generates next step of states
using previous states, parameters and Q
statesDerivative can be used as a placeholder for the derivative
Example:</p>
<dl class="docutils">
<dt>def model(u, states, parameters, statesDerivative, Q):</dt>
<dd>m = parameters[:, 0]
k = parameters[:, 1]
c = parameters[:, 2]
dt = 1.0
statesDerivative[:, 0] = states[:, 1]
statesDerivative[:, 1] = 1.0/m*(-k*states[:, 0] - c*states[:, 1] + (u + randn(states.shape[0])*np.sqrt(Q))
states[:, 0] += statesDerivative[:, 0]*dt
states[:, 1] += statesDerivative[:, 1]*dt</dd>
</dl>
</li>
<li><strong>nStates</strong> (<em>int</em>) – Number of states in the system</li>
<li><strong>nParameters</strong> (<em>int</em>) – Number of parameters in the system</li>
<li><strong>measuredStates</strong> (<em>int</em><em> or </em><em>array_like</em>) – Which state number are measured
Could be a single number or multiple in a list.
Observation (z) must have the same length.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="pyvib.ParticleFilter.ParticleFilter.createGaussianParticles">
<code class="descname">createGaussianParticles</code><span class="sig-paren">(</span><em>mean</em>, <em>var</em><span class="sig-paren">)</span><a class="headerlink" href="#pyvib.ParticleFilter.ParticleFilter.createGaussianParticles" title="Permalink to this definition">¶</a></dt>
<dd><p>Create gaussian distributed particles</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>mean</strong> (<em>array_like</em>) – Mean value of gaussian distributed guess
len(mean) = nStates + nParameters</li>
<li><strong>std</strong> (<em>array_like</em>) – Variation of gaussian distributed guess
len(var) = nStates + nParameters</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="pyvib.ParticleFilter.ParticleFilter.createUniformParticles">
<code class="descname">createUniformParticles</code><span class="sig-paren">(</span><em>ranges</em><span class="sig-paren">)</span><a class="headerlink" href="#pyvib.ParticleFilter.ParticleFilter.createUniformParticles" title="Permalink to this definition">¶</a></dt>
<dd><p>Create uniformly distributed particles</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>ranges</strong> (<em>2D numpy.ndarray</em>) – The uniform range of starting guess
Shaped as [nStates + nParamteres, 2]</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="pyvib.ParticleFilter.ParticleFilter.estimate">
<code class="descname">estimate</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pyvib.ParticleFilter.ParticleFilter.estimate" title="Permalink to this definition">¶</a></dt>
<dd><p>Estimates true value and variance of states and parameters
Results are saved in ParticleFilter.meanList and -.varList</p>
</dd></dl>

<dl class="method">
<dt id="pyvib.ParticleFilter.ParticleFilter.getMeanAndVariance">
<code class="descname">getMeanAndVariance</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pyvib.ParticleFilter.ParticleFilter.getMeanAndVariance" title="Permalink to this definition">¶</a></dt>
<dd><p>Get meanlist and varlist
Mean and var</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><ul class="simple">
<li><strong>meanList</strong> (<em>list of float 1D array</em>) – Mean of each state for each time step</li>
<li><strong>varList</strong> (<em>list of float 1D array</em>) – Variance of each state for each time step</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="pyvib.ParticleFilter.ParticleFilter.getPercentile">
<code class="descname">getPercentile</code><span class="sig-paren">(</span><em>per</em><span class="sig-paren">)</span><a class="headerlink" href="#pyvib.ParticleFilter.ParticleFilter.getPercentile" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the percentile of values</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>per</strong> (<em>float</em>) – Percentile &lt;0.0, 1.0&gt;</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>percentile</strong> – Percentiles</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">float 1D array</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="pyvib.ParticleFilter.ParticleFilter.get_parameters">
<code class="descname">get_parameters</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pyvib.ParticleFilter.ParticleFilter.get_parameters" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the parameters of particles</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><strong>parameters</strong> – Parameters of particles</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">float 2D array</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="pyvib.ParticleFilter.ParticleFilter.get_states">
<code class="descname">get_states</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pyvib.ParticleFilter.ParticleFilter.get_states" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the states of particles</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><strong>states</strong> – States of particles</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">float 2D array</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="pyvib.ParticleFilter.ParticleFilter.plotHistogram">
<code class="descname">plotHistogram</code><span class="sig-paren">(</span><em>column</em><span class="sig-paren">)</span><a class="headerlink" href="#pyvib.ParticleFilter.ParticleFilter.plotHistogram" title="Permalink to this definition">¶</a></dt>
<dd><p>Plot histogram of a state or parameter</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>column</strong> (<em>int</em>) – Which column of self.particles should be pltted</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="pyvib.ParticleFilter.ParticleFilter.predict">
<code class="descname">predict</code><span class="sig-paren">(</span><em>u</em><span class="sig-paren">)</span><a class="headerlink" href="#pyvib.ParticleFilter.ParticleFilter.predict" title="Permalink to this definition">¶</a></dt>
<dd><p>Predict state of next time step using control input</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>u</strong> (<em>float</em><em> or </em><em>array_like</em>) – The control input.
Must follow rules of model function</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="pyvib.ParticleFilter.ParticleFilter.resample">
<code class="descname">resample</code><span class="sig-paren">(</span><em>thrScale=0.5</em><span class="sig-paren">)</span><a class="headerlink" href="#pyvib.ParticleFilter.ParticleFilter.resample" title="Permalink to this definition">¶</a></dt>
<dd><p>Resamples particles IF necessary</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>thrScale</strong> (<em>float</em><em>, </em><em>optional</em>) – Thresholds for resampling scaled by number of particles</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="pyvib.ParticleFilter.ParticleFilter.simulateTrend">
<code class="descname">simulateTrend</code><span class="sig-paren">(</span><em>iterations, u, percs=[0.5]</em><span class="sig-paren">)</span><a class="headerlink" href="#pyvib.ParticleFilter.ParticleFilter.simulateTrend" title="Permalink to this definition">¶</a></dt>
<dd><p>Simulate the trend moving forward using the particles parameters and state</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>iterations</strong> (<em>int</em>) – Number of iterations to simulate</li>
<li><strong>u</strong> (<em>Data type defined by user in self.model</em>) – Control input</li>
<li><strong>percs</strong> (<em>list of floats</em><em>, </em><em>optional</em>) – Which percentile of parameters and states to simulate as true values</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>output</strong> – Simulation results
output[i, j, k] gives the following
i - the iteration
j - the percentile
k - the state number</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">float 3D array</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="pyvib.ParticleFilter.ParticleFilter.update">
<code class="descname">update</code><span class="sig-paren">(</span><em>z</em>, <em>debug=False</em><span class="sig-paren">)</span><a class="headerlink" href="#pyvib.ParticleFilter.ParticleFilter.update" title="Permalink to this definition">¶</a></dt>
<dd><p>Update the weights based on measurements and observation noise</p>
<dl class="docutils">
<dt>z <span class="classifier-delimiter">:</span> <span class="classifier">float or array_like:</span></dt>
<dd>The observation
len(z) == len(measuredStates)</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="function">
<dt id="pyvib.ParticleFilter.randn">
<code class="descclassname">pyvib.ParticleFilter.</code><code class="descname">randn</code><span class="sig-paren">(</span><em>d0</em>, <em>d1</em>, <em>...</em>, <em>dn</em><span class="sig-paren">)</span><a class="headerlink" href="#pyvib.ParticleFilter.randn" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a sample (or samples) from the “standard normal” distribution.</p>
<p>If positive, int_like or int-convertible arguments are provided,
<cite>randn</cite> generates an array of shape <code class="docutils literal notranslate"><span class="pre">(d0,</span> <span class="pre">d1,</span> <span class="pre">...,</span> <span class="pre">dn)</span></code>, filled
with random floats sampled from a univariate “normal” (Gaussian)
distribution of mean 0 and variance 1 (if any of the <span class="math notranslate nohighlight">\(d_i\)</span> are
floats, they are first converted to integers by truncation). A single
float randomly sampled from the distribution is returned if no
argument is provided.</p>
<p>This is a convenience function.  If you want an interface that takes a
tuple as the first argument, use <cite>numpy.random.standard_normal</cite> instead.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>d1</strong><strong>, </strong><strong>..</strong><strong>, </strong><strong>dn</strong> (<em>d0</em><em>,</em>) – The dimensions of the returned array, should be all positive.
If no argument is given a single Python float is returned.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>Z</strong> – A <code class="docutils literal notranslate"><span class="pre">(d0,</span> <span class="pre">d1,</span> <span class="pre">...,</span> <span class="pre">dn)</span></code>-shaped array of floating-point samples from
the standard normal distribution, or a single such float if
no parameters were supplied.</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">ndarray or float</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><code class="xref py py-func docutils literal notranslate"><span class="pre">standard_normal()</span></code></dt>
<dd>Similar, but takes a tuple as its argument.</dd>
</dl>
</div>
<p class="rubric">Notes</p>
<p>For random samples from <span class="math notranslate nohighlight">\(N(\mu, \sigma^2)\)</span>, use:</p>
<p><code class="docutils literal notranslate"><span class="pre">sigma</span> <span class="pre">*</span> <span class="pre">np.random.randn(...)</span> <span class="pre">+</span> <span class="pre">mu</span></code></p>
<p class="rubric">Examples</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">randn</span><span class="p">()</span>
<span class="go">2.1923875335537315 #random</span>
</pre></div>
</div>
<p>Two-by-four array of samples from N(3, 6.25):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="mf">2.5</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">randn</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">)</span> <span class="o">+</span> <span class="mi">3</span>
<span class="go">array([[-4.49401501,  4.00950034, -1.81814867,  7.29718677],  #random</span>
<span class="go">       [ 0.39924804,  4.68456316,  4.99394529,  4.84057254]]) #random</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="pyvib.ParticleFilter.uniform">
<code class="descclassname">pyvib.ParticleFilter.</code><code class="descname">uniform</code><span class="sig-paren">(</span><em>low=0.0</em>, <em>high=1.0</em>, <em>size=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pyvib.ParticleFilter.uniform" title="Permalink to this definition">¶</a></dt>
<dd><p>Draw samples from a uniform distribution.</p>
<p>Samples are uniformly distributed over the half-open interval
<code class="docutils literal notranslate"><span class="pre">[low,</span> <span class="pre">high)</span></code> (includes low, but excludes high).  In other words,
any value within the given interval is equally likely to be drawn
by <cite>uniform</cite>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>low</strong> (<em>float</em><em> or </em><em>array_like of floats</em><em>, </em><em>optional</em>) – Lower boundary of the output interval.  All values generated will be
greater than or equal to low.  The default value is 0.</li>
<li><strong>high</strong> (<em>float</em><em> or </em><em>array_like of floats</em>) – Upper boundary of the output interval.  All values generated will be
less than high.  The default value is 1.0.</li>
<li><strong>size</strong> (<em>int</em><em> or </em><em>tuple of ints</em><em>, </em><em>optional</em>) – Output shape.  If the given shape is, e.g., <code class="docutils literal notranslate"><span class="pre">(m,</span> <span class="pre">n,</span> <span class="pre">k)</span></code>, then
<code class="docutils literal notranslate"><span class="pre">m</span> <span class="pre">*</span> <span class="pre">n</span> <span class="pre">*</span> <span class="pre">k</span></code> samples are drawn.  If size is <code class="docutils literal notranslate"><span class="pre">None</span></code> (default),
a single value is returned if <code class="docutils literal notranslate"><span class="pre">low</span></code> and <code class="docutils literal notranslate"><span class="pre">high</span></code> are both scalars.
Otherwise, <code class="docutils literal notranslate"><span class="pre">np.broadcast(low,</span> <span class="pre">high).size</span></code> samples are drawn.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>out</strong> – Drawn samples from the parameterized uniform distribution.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">ndarray or scalar</p>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><code class="xref py py-func docutils literal notranslate"><span class="pre">randint()</span></code></dt>
<dd>Discrete uniform distribution, yielding integers.</dd>
<dt><code class="xref py py-func docutils literal notranslate"><span class="pre">random_integers()</span></code></dt>
<dd>Discrete uniform distribution over the closed interval <code class="docutils literal notranslate"><span class="pre">[low,</span> <span class="pre">high]</span></code>.</dd>
<dt><code class="xref py py-func docutils literal notranslate"><span class="pre">random_sample()</span></code></dt>
<dd>Floats uniformly distributed over <code class="docutils literal notranslate"><span class="pre">[0,</span> <span class="pre">1)</span></code>.</dd>
<dt><code class="xref py py-func docutils literal notranslate"><span class="pre">random()</span></code></dt>
<dd>Alias for <cite>random_sample</cite>.</dd>
<dt><code class="xref py py-func docutils literal notranslate"><span class="pre">rand()</span></code></dt>
<dd>Convenience function that accepts dimensions as input, e.g., <code class="docutils literal notranslate"><span class="pre">rand(2,2)</span></code> would generate a 2-by-2 array of floats, uniformly distributed over <code class="docutils literal notranslate"><span class="pre">[0,</span> <span class="pre">1)</span></code>.</dd>
</dl>
</div>
<p class="rubric">Notes</p>
<p>The probability density function of the uniform distribution is</p>
<div class="math notranslate nohighlight">
\[p(x) = \frac{1}{b - a}\]</div>
<p>anywhere within the interval <code class="docutils literal notranslate"><span class="pre">[a,</span> <span class="pre">b)</span></code>, and zero elsewhere.</p>
<p>When <code class="docutils literal notranslate"><span class="pre">high</span></code> == <code class="docutils literal notranslate"><span class="pre">low</span></code>, values of <code class="docutils literal notranslate"><span class="pre">low</span></code> will be returned.
If <code class="docutils literal notranslate"><span class="pre">high</span></code> &lt; <code class="docutils literal notranslate"><span class="pre">low</span></code>, the results are officially undefined
and may eventually raise an error, i.e. do not rely on this
function to behave when passed arguments satisfying that
inequality condition.</p>
<p class="rubric">Examples</p>
<p>Draw samples from the distribution:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">s</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">uniform</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">1000</span><span class="p">)</span>
</pre></div>
</div>
<p>All values are within the given interval:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">all</span><span class="p">(</span><span class="n">s</span> <span class="o">&gt;=</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">all</span><span class="p">(</span><span class="n">s</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">)</span>
<span class="go">True</span>
</pre></div>
</div>
<p>Display the histogram of the samples, along with the
probability density function:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">count</span><span class="p">,</span> <span class="n">bins</span><span class="p">,</span> <span class="n">ignored</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">hist</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="mi">15</span><span class="p">,</span> <span class="n">density</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">bins</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">ones_like</span><span class="p">(</span><span class="n">bins</span><span class="p">),</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;r&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h4>Previous topic</h4>
  <p class="topless"><a href="stats.html"
                        title="previous chapter">Statistical functions</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="acoustics.html"
                        title="next chapter">Acoustics functions</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="_sources/particlefilter.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="acoustics.html" title="Acoustics functions"
             >next</a> |</li>
        <li class="right" >
          <a href="stats.html" title="Statistical functions"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">Bearing Vibration Diagnostics Toolbox 1.0 documentation</a> &#187;</li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2019, Andreas Klausen.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.8.5.
    </div>
  </body>
</html>